#include <stdio.h>
#include <math.h>

int det2(float a11,float a12,float a21,float a22)
{
    float Det2;
    Det2=a11*a22-a21*a12;
    printf("The det2 is %f \n",Det2);
    return Det2;
}
int det3(float a11,float a12,float a13,float a21,float a22,float a23,float a31,float a32,float a33)
{
    float Det3;
    Det3=a11*det2(a22,a23,a32,a33)-a21*det2(a12,a13,a32,a33)+a31*det2(a12,a13,a22,a23);
    printf("The det3 is %f \n",Det3);
    return Det3;
}
int main ()
{
    float a11,a12,a13,a21,a22,a23,a31,a32,a33;
    int choose;
    printf("Please choose det type\nif 2-by2 input 1,if 3-by-3 input 2\n");
    scanf("%d",&choose);
    if (choose==1)
    {
        printf("Please constantly input a11,a12,a21,a22\n");
        scanf("%f%f%f%f",&a11,&a12,&a21,&a22);
        det2(a11,a12,a21,a22);
    }
    else
    {
        printf("Please constantly input a11,a12,a13,a21,a22,a23,a31,a32,a33\n");
        scanf("%f%f%f%f%f%f%f%f%f",&a11,&a12,&a13,&a21,&a22,&a23,&a31,&a32,&a33);
        det3(a11,a12,a13,a21,a22,a23,a31,a32,a33);
    }

    return 0;
}